<?php
	session_start();
	if(isset($_SESSION['usuario']))
	{ $user = $_SESSION['usuario'];}
	require_once('../conexion/conexion.php');
	$cod = $_POST['cod'];
	$fecha = date('d-m-Y');
	$con = new Conexion();
	$con2 = $con->conexionBD("fpproduccion");
	$sql = "select 
				ProNombre,
				date_format(BAFecha,'%d/%m/%Y') as fecha,
				BAResponsable,
				bodarea.BodCCod
				
				from bodarea
				inner join bodegacentral on
				bodegacentral.BodCCod=bodarea.BodCCod
				inner join producto on 
				producto.procod=bodegacentral.procod
				
				where BACod='".$cod."'";
	$resultado = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$datos = mysql_fetch_array($resultado);
	$con->cerrarBD();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<script src="../include_js/jquery.js" type="text/javascript"></script>
<script src="../include_js/funciones.js" type="text/javascript"></script>

<style>
.texto
{
	font-size:14px;
	margin-left:10px;
	font:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
}
.borde
{
	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.asterisco
{
	color:#0000FF;
	font-weight:bold;
}
.radioBorde
{ 
 background:#D3E4E5;
 border:0px solid #89C0C7;
}
.filaPar
{
	background:#81D371; 
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.filaImpar
{
	background:#AEF1A1;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
</style>
<script>
function Volver()
{
	$.ajax({
				type: 'POST',
				url: 'Carga_busqueda_Inventario_Area.php',
				data: $('#form_edicion').serialize(),
				success: function(data) {
					$('#mensaje').html(data);
				}
			})
}

function focoCant()
{
	document.getElementById('txtStock').focus();
}

function Direccionar()
{
	valor = document.getElementById('txtNum').value;
	if(valor!=0)
	{
		$.ajax({
				type: 'POST',
				url: 'Carga_busqueda_Inventario_Area.php',
				data: $('#form_edicion').serialize(),
				success: function(data) {
					$('#mensaje').html(data);
				}
			})
	}
}

function GuardarStock()
{
	$.ajax({
				type: 'POST',
				url: 'Ingresos/Ingreso_Edicion_stock_Area.php',
				data: $('#form_edicion').serialize(),
				success: function(data) {
					$('#mensaje2').html(data);
					Direccionar();
				}
			})
}
</script>
</head>

<body>
<form name="form_edicion" id="form_edicion" method="post">
<div class='option2'><label style="font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;">Edici&oacute;n de Stock.</label></div>
<div class='groupbox'>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="uno">
<tr>
  <td colspan="4" class="borde"><div style="height:5px;"></div></td>
</tr>
<tr>
	<td colspan="3" class="borde"><label class="texto" style="font-weight:bold;">Datos Producto.</label></td>
	<td width="37%" class="borde">&nbsp;</td>
</tr>
<tr>
  <td colspan="4" class="borde">&nbsp;</td>
</tr>

<tr>
  <td width="17%" class="borde" style="text-align:right"><label class="texto">Nombre:</label></td>
  <td width="30%" class="borde"><input type="text" name="txtNombre" id="txtNombre" size="30" readonly="true" style="background:#E1E1E1" value="<?php echo $datos[0];?>"/></td>
  <td width="16%" class="borde" style="text-align:right"><label class="texto">Cantidad:</label></td>
  <td class="borde"><input type="text" name="txtStock" id="txtStock" size="10" onkeypress="return validar(event)" /></td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Fecha Ingreso:</label></td>
  <td class="borde"><input name="txtFecha" type="text" id="txtFecha" size="30" readonly="true" style="background:#E1E1E1" value="<?php echo $datos[1];?>"></td>
  <td class="borde" style="text-align:right"><label class="texto">Fecha Edici&oacute;n:</label></td>
  <td class="borde"><input name="txtFecha" type="text" id="txtFecha" size="10" readonly="true" style="background:#E1E1E1" value="<?php echo $fecha;?>"></td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Responsable:</label></td>
  <td class="borde"><input type="text" name="textfield" size="30" readonly="true" style="background:#E1E1E1" value="<?php echo $datos[2];?>"/></td>
  <td class="borde" style="text-align:right">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde">&nbsp;</td>
  <td class="borde"><input name="cmb_Producto" id="cmb_Producto" type="hidden" value="<?php echo $_POST['prod']?>" />
<input name="cmb_Proveedor" id="cmb_Proveedor" type="hidden" value="<?php echo $_POST['prov']?>" />
<input name="txtFIni" id="txtFIni" type="hidden" value="<?php echo $_POST['fini']?>"/>
<input name="txtFFin" id="txtFFin" type="hidden" value="<?php echo $_POST['ffin']?>"/>
<input name="cmb_Area" id="cmb_Area" type="hidden" value="<?php echo $_POST['areaCod']?>"/></td>
  <td class="borde">&nbsp;</td>
  <td class="borde"><input type="hidden" name="txtNum" id="txtNum" value="0" />
    <input type="hidden" name="txtCodBodega" id="txtCodBodega" value="<?php echo $cod;?>"/>
    <input type="hidden" name="txtUsuario" id="txtUsuario" value="<?php echo $user;?>" />
    <input type="hidden" name="txtStockIni" id="txtStockIni" value="<?php echo $_POST['stock'];?>" /></td>
</tr>


<tr>
  <td class="borde" colspan="4"><div class="formtail"><input name="btn_Guardar" id="btn_Guardar" type="button" value=" " class="guardar"  onclick="GuardarStock();"/>
    <input type="button" name="btn_Volver" id="btn_Volver" value="Cancelar" onclick="Volver();" />
  </div></td>
</tr>
</table>
</div>
<div id="mensaje2"></div>
<?php
	echo "<script>focoCant();</script>";
?>
</form>
</body>
</html>
